import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

/// @date 2020/07/21  16:55
/// @author 程志强
/// @des

class CustomScrollViewRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: CustomScrollView(
        slivers: <Widget>[
          // app bar
          SliverAppBar(
            pinned: true,
            expandedHeight: 220.0,
            backgroundColor: Colors.lightGreen,
            flexibleSpace: FlexibleSpaceBar(
              title: const Text("demo"),
              background: Image.network(
                "https://img.ivsky.com/img/tupian/pre/202003/01/valencia-011.jpg",
                fit: BoxFit.fill,
              ),
            ),
          ),
          SliverPadding(
            padding: const EdgeInsets.all(8.0),
            sliver: SliverGrid(
                delegate: SliverChildBuilderDelegate((context, index) {
                  return Container(
                    alignment: Alignment.center,
                    color: Colors.cyan[100 * (index % 9)],
                    child: Text("grid item $index"),
                  );
                }, childCount: 10),
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    mainAxisSpacing: 10.0,
                    crossAxisSpacing: 10.0,
                    childAspectRatio: 4.0)),
          ),
          SliverFixedExtentList(
            itemExtent: 100.0,
            delegate:
                SliverChildBuilderDelegate((context, index) {
                  return Container(
                    alignment: Alignment.center,
                    color: Colors.lightBlue[100 * (index % 9)],
                    child: Text("list item $index"),
                  );
                }, childCount: 50),
          )
        ],
      ),
    );
  }
}
